# coding=utf-8


def wordcount(count_dict, str1):
    # 文章字符串前期处理
#     strl_ist = str.replace('\n', '').lower().split(' ')
    strl_ist = str1.split()
    
    # 如果字典里有该单词则加1，否则添加入字典
    for str in strl_ist:
        if str in count_dict.keys():
            count_dict[str] = count_dict[str] + 1
        else:
            count_dict[str] = 1
    # 按照词频从高到低排列
    
#     return count_list


if __name__ == '__main__':
    count_dict = {}
    
    with open('1.txt', 'rb') as f:
        for s1 in f.readlines():
#             print(s1 + "\n\n")
            wordcount(count_dict, s1)
    
#     print(count_dict)
    count_list = sorted(count_dict.items(), key=lambda x:x[1], reverse=True)
    print(count_list)